<?php
    
    $lat_a=25.004804;
    $lng_a=102.683838;
    $lat_b=25.004512;
    $lng_b=102.684423;
    
    
    $pk = 180/3.1415926;
    $a1 = $lat_a/$pk;
    $a2 = $lng_a/$pk;
    $b1 = $lat_b/$pk;
    $b2 = $lng_b/$pk;
    $t1 = cos($a1)*cos($a2)*cos($b1)*cos($b2);
    $t2 = cos($a1)*sin($a2)*cos($b1)*sin($b2);
    $t3 = sin($a1)*sin($b1);
    $tt = acos($t1 + $t2 + $t3);
    $ss = 6366000*$tt;
    echo $ss;
